import { _decorator, Component, Node, Button, Sprite, EventTarget, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Card')
export class Card{
    cardView: Node = null
    cardSprite: Node = null
    cardIndex: number = 0
    url: string = ""

    initEvent(callback: Function){
        this.cardSprite.on('click', callback, this)
    }

    test(evet){
        console.log(evet)
    }

    //变灰
    setGray(flag: boolean){
        const squareSprite = this.cardView.getComponent(Sprite)
        squareSprite.grayscale = flag

        const cardSprite = this.cardSprite.getComponent(Sprite)
        cardSprite.grayscale = flag

        this.setButton(!flag)
    }

    setButton(flag:boolean){
        const button = this.cardSprite.getComponent(Button)
        button.interactable = flag
        console.log(button)
    }
}


@ccclass('ImageRes')
export class ImageRes{
    spriteFrame: SpriteFrame = null
    name: string = ""
}